var _n54;
var cc__extends = __extends;
var cc__decorate = __decorate;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $1$EventManager = require("EventManager");
var s = cc__importDefault($1$EventManager);
var $1$Loader = require("Loader");
var c = cc__importDefault($1$Loader);
var $1$yyComponent = require("yyComponent");
var l = cc__importDefault($1$yyComponent);
var $GameEventType = require("GameEventType");
var $zqcc_OverallSystem = require("zqcc_OverallSystem");
var $gameMode_Json = require("gameMode_Json");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_gameListItem = function (t) {
  function _ctor() {
    const instance = null !== t && t.apply(this, arguments) || this;
    instance.icon = null;
    instance.vicon = null;
    instance.gameName = null; // 修正变量名拼写错误
    instance.lockNode = null;
    instance.huise = null;
    instance.zhengchang = null;
    instance.data = null; // 确保所有属性初始化为null
    return instance; // 返回实例
  }
  cc__extends(_ctor, t);
  _ctor.prototype.start = function () {
    this.on($GameEventType.EventType.UIEvent.updataGamelist, this.updataView, this);
  };
  _ctor.prototype.setData = function (t) {
    cc.log(t);
    this.data = t;
    this.updataView();
  };
  _ctor.prototype.updataView = function () {
    // 优化后的代码
    const context = this; // 使用const替代var，并且修改变量名为更具意义的名称
    if (this.data) {
      const data = this.data; // 使用const替代var以提高可读性
      this.gameName.string = `${data.name}`; // 使用模板字符串提升可读性

      // 校验关卡是否在游戏列表或键值为1
      if ($zqcc_OverallSystem.sers().userSrv.getGuanqiaGameList().includes(+data.key) || +data.key === 1) {
        this.vicon.active = false;
        this.lockNode.active = true;
      }

      // 加载资源
      c.default.loadBundleRes("Majiang", `guanqiaicon/${this.data.id}`, function (resource) {
        if (context && context.node) {
          context.icon.spriteFrame = new cc.SpriteFrame(resource); // 使用更具说明性的变量名
        }
      });
    }
  };
  _ctor.prototype.onTouchStart = function () {
    const context = this; // 使用const替代var，修改变量名为更具意义的名称
    $zqcc_OverallSystem.mgrs().soundMgr.playBtnSound();

    if (this.vicon.active) {
      // 加载和显示视频广告
      $zqcc_OverallSystem.sers().platformSrv.platformApi.loadAndShowVideoAd(
        function () {
          const gameList = $zqcc_OverallSystem.sers().userSrv.getGuanqiaGameList();
          gameList.push(+context.data.key); // 追加当前关卡键值
          $zqcc_OverallSystem.sers().userSrv.setGuanqiaGameList(gameList);
          s.default.emit($GameEventType.EventType.UIEvent.updataGamelist); // 更新游戏列表
        },
        function () { },
        null,
        {
          scene: "关卡模式解锁",
          event: `解锁${context.data.name}` // 使用模板字符串提升可读性
        },
        "common_video"
      );
    } else {
      // 设定窗口属性并进入指定模式
      window.guanqiaMODE = this.data.id;
      window.guanqiaMODE_name = this.data.name;
      window.guanqiaMODE_key = this.data.key;
      $zqcc_OverallSystem.mgrs().gameMgr.enterMode($gameMode_Json.GAME_MODE.MAJIANGLEVEL);
    }
  };
  cc__decorate([ccp_property(cc.Sprite)], _ctor.prototype, "icon", undefined);
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "vicon", undefined);
  cc__decorate([ccp_property(cc.Label)], _ctor.prototype, "gameNmae", undefined);
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "lockNode", undefined);
  cc__decorate([ccp_property(cc.Material)], _ctor.prototype, "huise", undefined);
  cc__decorate([ccp_property(cc.Material)], _ctor.prototype, "zhengchang", undefined);
  return cc__decorate([ccp_ccclass], _ctor);
}(l.default);
exports.default = def_gameListItem;